using B.S.XZYData.Api.Wrter.Application.Command.Approval;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace B.S.XZYData.Api.Wrter.Controllers
{
    /// <summary>
    /// 审批操作接口
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class ApprovalController : ControllerBase
    {
        private readonly IMediator _mediator;

        public ApprovalController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 处理审批（通过/驳回）
        /// </summary>
        /// <param name="command">审批操作命令</param>
        /// <returns>处理结果</returns>
        [HttpPost]
        public async Task<IActionResult> ProcessApproval([FromBody] ProcessApprovalCommand command)
        {
            var result = await _mediator.Send(command);
            return Ok(result);
        }

        /// <summary>
        /// 重新提交申请
        /// </summary>
        /// <param name="command">重新提交命令</param>
        /// <returns>处理结果</returns>
        [HttpPost]
        public async Task<IActionResult> ResubmitApplication([FromBody] ResubmitApplicationCommand command)
        {
            var result = await _mediator.Send(command);
            return Ok(result);
        }

        /// <summary>
        /// 撤回申请
        /// </summary>
        /// <param name="command">撤回申请命令</param>
        /// <returns>处理结果</returns>
        [HttpPost]
        public async Task<IActionResult> WithdrawApplication([FromBody] WithdrawApplicationCommand command)
        {
            var result = await _mediator.Send(command);
            return Ok(result);
        }

        /// <summary>
        /// 批量审批
        /// </summary>
        /// <param name="command">批量审批命令</param>
        /// <returns>批量处理结果</returns>
        [HttpPost]
        public async Task<IActionResult> BatchProcessApproval([FromBody] BatchProcessApprovalCommand command)
        {
            var result = await _mediator.Send(command);
            return Ok(result);
        }
    }
} 